From: Keir Fraser Date: Fri, 19 Jun 2009 07:42:58 +0000 (+0100) Subject: P2M: check whether hap mode is enabled before using 2mb pages X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13725 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0ca1669871f8a;p=xen.git P2M: check whether hap mode is enabled before using 2mb pages This small patch checks whether hap mode is enabled when guest is trying to allocate 2MB pages inside P2M. This prevents potential errors when hap is disabled. Cc: Chris Lalancette Cc: Sarathy, Bhavna Signed-off-by: Wei Huang --- diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 257641971a..f410aaec40 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1499,7 +1499,11 @@ int set_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, while ( todo ) { - order = (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? 9 : 0; + if ( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled ) + order = (((gfn | mfn_x(mfn) | todo) & ((1ul << 9) - 1)) == 0) ? + 9 : 0; + else + order = 0; rc = d->arch.p2m->set_entry(d, gfn, mfn, order, p2mt); gfn += 1ul << order; if ( mfn_x(mfn) != INVALID_MFN )